﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AspNetCs.Bll;
using System.Data;
using System.Text;
using AspNetCs.Common;
using AspNetCs.Model;
using AspNetCs.Enumerations.Channel_Enum;
using AspNetCs.Enumerations.User_Enum;
using AspNetCs.Enumerations.TrueOrFalseEnum;
public partial class index_Default : BasePage
{
    //网站动态文章类别编号
    protected int siteNewsClassId = 9;
    //网站动态文章显示行数
    private readonly int SiteNewsCount = 10;

    //行业动态文章类别编号
    protected int industryNewsClassId = 3;
    //行业动态文章显示行数
    private readonly int IndustryNewsCount = 10;

    //客户服务文章类别编号
    protected int customerSeviceClassId = 10;
    //客户服务文章显示行数
    private readonly int CustomerSeviceCount = 10;

    //纪念文选文章类别编号
    protected int memorialArticleClassId = 1;
    //纪念文选文章显示行数
    private readonly int MemorialArticleCount = 7;

    //法规与文化文章类别编号
    protected int cultureArticleClassId = 4;
    //法规与文化文章显示行数
    private readonly int CultureArticleCount = 7;

    //海内外寻亲显示行数
    private readonly int FindFamilyCount = 8;

    protected int city = 0;
    protected int pro = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        DnsRequest.UrlRequestAgentName(out city, out pro);
    }

    /// <summary>
    /// 网站动态文章
    /// </summary>
    /// <returns></returns>
    public DataTable GetSiteNewsList()
    {
        DataTable dataTable = new DataTable();
        string cmdText = "select top {0} ArticleId,Title,UpdateTime,IsTop from Article where ClassID={1} and IsDel=0 and IsPassed=1 order by IsTop desc,ArticleId desc";
        cmdText = string.Format(cmdText, SiteNewsCount, siteNewsClassId);
        dataTable = ExcuteSqlTextBLL.GetDataTable(cmdText);
        return dataTable;
    }

    /// <summary>
    /// 网站动态文章显示
    /// </summary>
    /// <returns></returns>
    public string DisplaySiteNewsList()
    {
        StringBuilder sb = new StringBuilder();
        DataTable dataTable = new DataTable();
        dataTable = GetSiteNewsList();
        sb.Append("<ul>");
        foreach (DataRow row in dataTable.Rows)
        {
            // sb.AppendFormat("<li style='width:365px;float:left;'><a href='{0}'><img src='{1}' />{2}</a></li><li style='width:95px;float:left;'>[{3}]</li>", configInfo.InstallDir + "NewsInfoShow_" + siteNewsClassId + "_" + row["ArticleId"] + ".aspx", StringHelper.isNumber_int(row["IsTop"].ToString()) == 0 ? configInfo.InstallDir + "Images/article_common.gif" : configInfo.InstallDir + "Images/article_ontop.gif", StringHelper.stringformat(row["Title"].ToString(),54), StringHelper.isDatetime(row["UpdateTime"].ToString()).ToString("yyyy年M月d日"));
            sb.AppendFormat("<li style='width:365px;float:left;line-height:20px;height:18px;'><img src='{1}' />&nbsp;<a href='{0}'  target='_blank' >{2}</a></li><li style='width:95px;float:left;'><span style='color:#666666'>[{3}]</span></li>", configInfo.InstallDir + "NewsInfoShow_" + siteNewsClassId + "_" + row["ArticleId"] + ".aspx", StringHelper.isNumber_int(row["IsTop"].ToString()) == 0 ? configInfo.InstallDir + "Images/article_common.gif" : configInfo.InstallDir + "Images/article_ontop.gif", StringHelper.stringformat(row["Title"].ToString(), 54), StringHelper.isDatetime(row["UpdateTime"].ToString()).ToString("yyyy年M月d日"));
        }
        sb.Append("</ul>");
        return sb.ToString();
    }

    /// <summary>
    /// 行业动态文章
    /// </summary>
    /// <returns></returns>
    public DataTable GetIndustryNewsList()
    {
        DataTable dataTable = new DataTable();
        string cmdText = "select top {0} ArticleId,Title,UpdateTime,IsTop from Article where ClassID={1} and IsDel=0 and IsPassed=1 order by IsTop desc,ArticleId desc";
        cmdText = string.Format(cmdText, IndustryNewsCount, industryNewsClassId);
        dataTable = ExcuteSqlTextBLL.GetDataTable(cmdText);
        return dataTable;
    }

    /// <summary>
    /// 行业动态文章显示
    /// </summary>
    /// <returns></returns>
    public string DisplayIndustryNewsList()
    {
        StringBuilder sb = new StringBuilder();
        DataTable dataTable = new DataTable();
        dataTable = GetIndustryNewsList();
        sb.Append("<ul>");
        foreach (DataRow row in dataTable.Rows)
        {
            //sb.AppendFormat("<li style='width:365px;float:left;'><a href='{0}'><img src='{1}' />{2}</a></li><li style='width:95px;float:left;'>[{3}]</li>", configInfo.InstallDir + "NewsInfoShow_" + industryNewsClassId + "_" + row["ArticleId"] + ".aspx", StringHelper.isNumber_int(row["IsTop"].ToString()) == 0 ? configInfo.InstallDir + "Images/article_common.gif" : configInfo.InstallDir + "Images/article_ontop.gif", StringHelper.stringformat(row["Title"].ToString(), 54), StringHelper.isDatetime(row["UpdateTime"].ToString()).ToString("yyyy年M月d日"));
            sb.AppendFormat("<li style='width:365px;float:left;line-height:20px;height:18px;'><img src='{1}' />&nbsp;<a href='{0}' target='_blank' >{2}</a></li><li style='width:95px;float:left;'><span style='color:#666666'>[{3}]</span></li>", configInfo.InstallDir + "NewsInfoShow_" + siteNewsClassId + "_" + row["ArticleId"] + ".aspx", StringHelper.isNumber_int(row["IsTop"].ToString()) == 0 ? configInfo.InstallDir + "Images/article_common.gif" : configInfo.InstallDir + "Images/article_ontop.gif", StringHelper.stringformat(row["Title"].ToString(), 54), StringHelper.isDatetime(row["UpdateTime"].ToString()).ToString("yyyy年M月d日"));
        }
        sb.Append("</ul>");
        return sb.ToString();
    }



    /// <summary>
    /// 客户服务文章
    /// </summary>
    /// <returns></returns>
    public DataTable GetCustomerSeviceList()
    {
        DataTable dataTable = new DataTable();
        string cmdText = "select className,classId from ArticleClass where parentId={0}";
        cmdText = string.Format(cmdText, customerSeviceClassId);
        dataTable = ExcuteSqlTextBLL.GetDataTable(cmdText);
        return dataTable;
    }

    /// <summary>
    /// 客户服务文章显示
    /// </summary>
    /// <returns></returns>
    public string DisplayCustomerSeviceList()
    {
        StringBuilder sb = new StringBuilder();
        DataTable dataTable = new DataTable();
        dataTable = GetCustomerSeviceList();
        sb.Append("<ul>");
        sb.Append("<li><img src='" + configInfo.InstallDir + "Images/tree_folder4.gif'><strong>客服中心</strong></li>");
        foreach (DataRow row in dataTable.Rows)
        {
            sb.AppendFormat("<li><img src='" + configInfo.InstallDir + "Images/tree_line1.gif' /><img src='" + configInfo.InstallDir + "Images/tree_folder3.gif' /><a href='{0}'  target='_blank'  >{1}</a></li>", configInfo.InstallDir + "CustomerSeviceList_" + row["ClassId"].ToString() + ".aspx", row["className"].ToString());
            //sb.AppendFormat("<li><a href='{0}'><img src='{1}' />{2}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[{3}]</a></li>", configInfo.InstallDir + "NewsInfoShow_" + customerSeviceClassId + "_" + row["ArticleId"] + ".aspx", StringHelper.isNumber_int(row["IsTop"].ToString()) == 0 ? configInfo.InstallDir + "Images/article_common.gif" : configInfo.InstallDir + "Images/article_ontop.gif", row["Title"].ToString(), row["UpdateTime"].ToString());
        }
        sb.Append("</ul>");
        return sb.ToString();
    }

    /// <summary>
    /// 纪念文选文章
    /// </summary>
    /// <returns></returns>
    public DataTable GetMemorialArticleList()
    {
        DataTable dataTable = new DataTable();
        string cmdText = "select top {0} ArticleId,Title,UpdateTime,IsTop from Article where ClassID={1} and IsDel=0 and IsPassed=1 order by IsTop desc,ArticleId desc";
        cmdText = string.Format(cmdText, MemorialArticleCount, memorialArticleClassId);
        dataTable = ExcuteSqlTextBLL.GetDataTable(cmdText);
        return dataTable;
    }

    /// <summary>
    /// 纪念文选文章显示
    /// </summary>
    /// <returns></returns>
    public string DisplayMemorialArticleList()
    {
        StringBuilder sb = new StringBuilder();
        DataTable dataTable = new DataTable();
        dataTable = GetMemorialArticleList();
        sb.Append("<ul>");
        foreach (DataRow row in dataTable.Rows)
        {
            sb.AppendFormat("<li style='width:228px;float:left;' class='{1}'><a href='{0}' target='_blank' >{2}</a></li><li style='width:95px;float:left;float:left;'>[{3}]</li>", configInfo.InstallDir + "NewsInfoShow_" + memorialArticleClassId + "_" + row["ArticleId"] + ".aspx", StringHelper.isNumber_int(row["IsTop"].ToString()) == 0 ? "statute_375_CommTitle" : "statute_375_Title", StringHelper.stringformat(row["Title"].ToString(), 32), StringHelper.isDatetime(row["UpdateTime"].ToString()).ToString("yyyy年M月d日"));
        }
        sb.Append("</ul>");
        return sb.ToString();
    }


    /// <summary>
    /// 法规与文化文章
    /// </summary>
    /// <returns></returns>
    public DataTable GetCultureArticleList()
    {
        DataTable dataTable = new DataTable();
        string cmdText = "select top {0} ArticleId,Title,UpdateTime,IsTop from Article where ClassID={1} and IsDel=0 and IsPassed=1 order by IsTop desc,ArticleId desc";
        cmdText = string.Format(cmdText, CultureArticleCount, cultureArticleClassId);
        dataTable = ExcuteSqlTextBLL.GetDataTable(cmdText);
        return dataTable;
    }

    /// <summary>
    /// 法规与文化文章显示
    /// </summary>
    /// <returns></returns>
    public string DisplayCultureArticleList()
    {
        StringBuilder sb = new StringBuilder();
        DataTable dataTable = new DataTable();
        dataTable = GetCultureArticleList();
        sb.Append("<ul>");
        foreach (DataRow row in dataTable.Rows)
        {
            sb.AppendFormat("<li style='width:228px;float:left;float:left;' class='{1}'><a href='{0}'  target='_blank' >{2}</a></li><li style='width:95px;float:left;float:left;'>[{3}]</li>", configInfo.InstallDir + "NewsInfoShow_" + cultureArticleClassId + "_" + row["ArticleId"] + ".aspx", StringHelper.isNumber_int(row["IsTop"].ToString()) == 0 ? "statute_375_CommTitle" : "statute_375_Title", StringHelper.stringformat(row["Title"].ToString(), 32), StringHelper.isDatetime(row["UpdateTime"].ToString()).ToString("yyyy年M月d日"));
        }
        sb.Append("</ul>");
        return sb.ToString();
    }


    /// <summary>
    /// 海内外寻亲
    /// </summary>
    /// <returns></returns>
    public DataTable GetFindFamily()
    {
        DataTable dataTable = new DataTable();
        string cmdText = "select top {0} Id,LostPerInfo,ContactAddress,RegisterTime,title from FindFamily  where IsCheck=1 and isdel=0  order by  AcceeCount desc,  RegisterTime desc";
        cmdText = string.Format(cmdText, this.FindFamilyCount);
        dataTable = ExcuteSqlTextBLL.GetDataTable(cmdText);
        return dataTable;
    }

    /// <summary>
    /// 海内外寻亲显示
    /// </summary>
    /// <returns></returns>
    public string DisplayFindFamilyList()
    {
        StringBuilder sb = new StringBuilder();
        DataTable dataTable = new DataTable();
        dataTable = GetFindFamily();
        if (dataTable.Rows.Count > 0)
        {
            sb.Append("<ul style=\"float:left;\">");
            foreach (DataRow row in dataTable.Rows)
            {
                sb.AppendFormat("<li style='width:340px;float:left;' class='{1}'><a href='{0}' style='float:left;' target='_blank' >{2}</a></li><li style='width:95px;float:left;'>[{3}]</li>", configInfo.InstallDir + "NewsInfoShow_" + cultureArticleClassId + "_" + row["Id"] + ".aspx", "statute_375_CommTitle", StringHelper.stringformat(StringHelper.RemoveHtml(row["title"].ToString()), 32), StringHelper.isDatetime(row["RegisterTime"].ToString()).ToString("yyyy年M月d日"));
            }
            sb.Append("</ul>");
        }
        else
        {
            sb.Append("<center><br><br>暂时没有信息<br></center>");
        }
        return sb.ToString();
    }

    /// <summary>
    /// 最新纪念
    /// </summary>
    /// <returns></returns>
    public string IndeNewsMassage()
    {
        StringBuilder stb = new StringBuilder();
        try
        {
            DataTable Dt = ExcuteSqlTextBLL.GetDataTable("Select Top 10 * from SacrificeList as s  where s.channelId='" + Channel_Type.memorial.ToString() + "'  order by s.Addtime desc");

            if (Dt.Rows.Count > 0)
            {
                stb.AppendLine("<ul>");
                stb.AppendLine("<li>");
                stb.AppendLine("<marquee direction='up' scrollamount='2' height='200'  onMouseOver='this.stop()' onMouseOut='this.start()'>");
                foreach (DataRow dr in Dt.Rows)
                {
                    SacrificeList_Model ThisMd = SacrificeList_Bll.CreateNew.GetModel(dr);
                    memorial_model MeMd = Memorial_Bll.CreateNew.GetModel(ThisMd.TypeId);

                    stb.AppendLine("<table width='95%' align='center' border='0' cellspacing='0' cellpadding='0' >");
                    stb.AppendLine("<tr> <td colspan=2 height='25' align='left' valign=top><img src='" + configInfo.InstallDir + "images/index_ci.jpg' align='absmiddle' />&nbsp;" + StringHelper.stringformat(StringHelper.RemoveHtml(ThisMd.Content), 30) + "</td></tr>	<tr>  <td width='60%' align='left' ><img src='" + configInfo.InstallDir + "images/ico_guan.gif' align='absmiddle' />&nbsp;<a href='" + DnsRequest.UrlDomainChange(MeMd.NumId, Channel_Type.memorial.ToString()) + "' target='_blank' >" + MeMd.NumId + "</a></td><td  align='left' width='60%'><img src='" + configInfo.InstallDir + "images/ico_shi.gif' align='absmiddle' />&nbsp;" + StringHelper.isDatetime(ThisMd.Addtime).ToString("yyyy-MM-dd") + "&nbsp;</td></tr>	<tr><td  align='left' colspan=2><hr noshed></td> </tr>");
                    stb.AppendLine("</table>");
                }
                stb.AppendLine("</marquee>");
                stb.AppendLine("</li>");

                stb.AppendLine("</ul>");
            }
            else
            {
                stb.AppendLine("<center><br><br>暂无信息<br><br></center>");
            }
        }
        catch
        {
            return "";
        }

        return stb.ToString();
    }

    /// <summary>
    /// 雁过留声
    /// </summary>
    /// <returns></returns>
    public string IndexGuestList()
    {
        StringBuilder stb = new StringBuilder();
        try
        {

            DataTable Dt = ExcuteSqlTextBLL.GetDataTable("Select Top 10 * from Guest    order by AdminReplyTime desc,GuestTime desc");
            if (Dt.Rows.Count > 0)
            {
                stb.AppendLine("<ul>");

                foreach (DataRow dr in Dt.Rows)
                {
                    string IsReplay = "";
                    if (dr["AdminReply"].ToString() + "" != "")
                    {
                        IsReplay = "<span style='color:#4474A3;'>[已回复]</span>";
                    }
                    stb.AppendLine("<li>");
                    stb.AppendLine("<div style='text-align:left;width:90%;height:18px;'><font color=#ff9900>·&nbsp;</font><a href='Guest/Default.aspx'>" + StringHelper.stringformat(StringHelper.RemoveHtml(dr["GuestTitle"].ToString()), 32) + "</a>" + IsReplay + "</div>");
                    stb.AppendLine("</li>");
                }

                stb.AppendLine("</ul>");
            }
            else
            {
                stb.AppendLine("<center><br><br>暂无信息<br><br></center>");
            }
        }
        catch
        {


        }


        return stb.ToString();
    }
    /// <summary>
    /// 合作同盟
    /// </summary>
    /// <returns></returns>
    public string WebLinkGood()
    {
        StringBuilder stb = new StringBuilder();
        try
        {
            DataTable dt = ExcuteSqlTextBLL.GetDataTable("Select Top 20 * from FriendSite Where IsCheck=" + (int)IsTrueEnum.Yes + " and  LinkType=" + (int)LinkTypeEnum.MyFriend + " order by IsGood desc,Addtime desc");

            stb.AppendLine("<ul><marquee direction='up' scrollamount='1' height=150   align='middle'>");
            foreach (DataRow dr in dt.Rows)
            {
                FriendSite_Model ThisMd = FriendSite_Bll.CreateNew.GetModel(dr);
                stb.AppendLine("<li><a href='" + ThisMd.SiteUrl + "' target='_blank' ><img src='" + ThisMd.LogoUrl + "'  width=100 border=0  style=' border:1px solid #cccccc'/></a></li>");
            }
            stb.AppendLine("</marquee></ul>");
        }
        catch
        {
            return "";

        }

        return stb.ToString();
    }

    public override string UI_TopControl()
    {

        return base.UI_TopControl(true, city, pro);
    }
    public override string UI_Head()
    {
        return base.UI_Head(configInfo.SiteTitle, configInfo.Meta_Keywords, configInfo.Meta_Description, city, pro);
    }
}
